$(function() {
	var t = [".ui-btn", ".ui-bar item", ".ui-list .list-item"];
	$(t).each(function(t, e) {
		$(document).delegate(e, "tap", function() {
			var t = $(this);
			t.addClass("hover"), setTimeout(function() {
				t.removeClass("hover")
			}, 100)
		})
	})
}), $(function() {
	$.lazy = function() {
		var t = '<div class="ui-widget" data-top="10" data-xtype="loading" data-size="little"><span class="icon"></span><span class="text">正在加载中...</span></div>',
			e = Array.prototype.slice.call(arguments),
			n = e[0],
			i = n.find('[data-wrap="dom"]'),
			a = e[1];
		console.log(a);
		var o = a ? a : n.data("param"),
			r = n.find("[type='text/html']"),
			s = r.html(),
			c = n.data("url") + "?" + o,
			u = n.data("namespace") || "temp",
			l = n.data("status");
		console.log(c), (!l || a) && (i.html(t), $.ajax({
			type: "GET",
			url: c,
			dataType: "json",
			timeout: 5e4,
			success: function(t) {
				if (window.dataPeel = window.dataPeel || {}, window.dataPeel[u] = t, console.log(window.dataPeel), o) {
					var e = o.split("&");
					t.params = {}, $.each(e, function(e, n) {
						var i = n.split("=");
						t.params[i[0]] = i[1]
					})
				}
				console.log(t), i.html($.tmpl(s, t)), n.attr("data-status", "loaded"), window.lazyLoad && window.lazyLoad(t)
			},
			error: function() {
				alert("获取失败，请稍候再试！")
			}
		}))
	};
	var t = $("[view]").eq(0),
		e = t.find("[data-lazy='true']");
	$(e).each(function(t, e) {
		$.lazy($(e))
	})
}), $(function() {
	var t = {};
	$.tmpl = function e(n, i) {
		var a = /\W/.test(n) ? new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + n.replace(/[\r\t\n]/g, " ").split("<%").join("	").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split("	").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');") : t[n] = t[n] || e(document.getElementById(n).innerHTML);
		return i ? a(i) : a
	}, $.tpl = function(t) {
		var e = new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + t.replace(/[\r\t\n]/g, " ").split("<%").join("	").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split("	").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');");
		return e
	}
}), !
function() {
	function t(t, e, n, i, a) {
		return Math.abs(t - n) < a && Math.abs(e - i) < a
	}
	if (window.navigator.userAgent.match(/(iPhone|iPad|iPod)/)) {
		var e = {
			TOUCH_MOVE_THRESHHOLD: 10,
			PRESSED_CLASS: "pressed",
			GHOST_CLICK_TIMEOUT: 500,
			GHOST_CLICK_THRESHOLD: 10
		},
			n = [];
		document.addEventListener("click", function(i) {
			for (var a = 0; a < n.length; a++) if (t(n[a][0], n[a][1], i.clientX, i.clientY, e.GHOST_CLICK_THRESHOLD)) return i.preventDefault(), void i.stopPropagation()
		}, !0), $(document).on("touchstart", '[data-hack="tap"]', function(n) {
			var i = $(this);
			i.css("webkitTapHighlightColor", "rgba(0,0,0,0)"), i.addClass(e.PRESSED_CLASS);
			var a = n.originalEvent.touches[0],
				o = [a.clientX, a.clientY];
			this.__eventLocation = o, this.__onTouchMove = function(n) {
				var a = n.originalEvent.touches[0];
				t(a.clientX, a.clientY, o[0], o[1], e.TOUCH_MOVE_THRESHHOLD) ? i.addClass(e.PRESSED_CLASS) : i.removeClass(e.PRESSED_CLASS)
			}, $(document.body).on("touchmove", this.__onTouchMove)
		}), $(document).on("touchcancel", '[data-hack="tap"]', function() {
			var t = $(this);
			t.removeClass(e.PRESSED_CLASS), $(document.body).off("touchmove", this.__onTouchMove)
		}), $(document).on("touchend", '[data-hack="tap"]', function(i) {
			var a = $(this);
			if (a.hasClass(e.PRESSED_CLASS)) {
				a.removeClass(e.PRESSED_CLASS);
				var o = this.__eventLocation;
				if (o) {
					var r = i.originalEvent.changedTouches[0];
					if (!t(r.clientX, r.clientY, o[0], o[1], e.TOUCH_MOVE_THRESHHOLD)) return;
					setTimeout(function() {
						var t = document.createEvent("MouseEvents");
						t.initMouseEvent("click", !0, !0, window, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), a.get(0).dispatchEvent(t)
					}, 1), i.preventDefault();
					var s = [r.clientX, r.clientY];
					n.push(s), window.setTimeout(function() {
						var t = n.indexOf(s);
						t >= 0 && n.splice(t, 1)
					}, e.GHOST_CLICK_TIMEOUT)
				}
			}
			$(document.body).off("touchmove", this.__onTouchMove)
		})
	}
}(), $(function() {
	$.viewList = [$("[view]").eq(0)], $.view = function(t) {
		var e = $.viewList[$.viewList.length - 1];
		console.log(e), e && e.hide(), $("[view]").hide();
		var n = $('[view="' + t + '"]');
		$.viewList.push(n), $("input").blur(), n.show(), window.curruntView = t, $(".MiniWrap").scrollTop(0)
	}, $(document).delegate('[data-tap^="view:"]', "click", function() {
		var t = $(this).data("tap").split(":")[1];
		setTimeout(function() {
			$.view(t), window.curruntView = t
		}, 100)
	})
}), $(function() {
	$(document).delegate(".dialog .close", "touchend", function() {
		var t = $(this).parents(".dialog");
		console.log(t), setTimeout(function() {
			t.hide()
		}, 350)
	})
}), $(document).delegate(".ui-select select", "change", function() {
	var t = $(this).parents(".ui-select").find(".value-bar"),
		e = $(this).find("option").not(function() {
			return !this.selected
		});
	value = e.attr("value"), text = e.text(), t.attr("data-value", value), t.html(text), "" == value && t.removeAttr("data-value")
}), $(document).delegate("[type='number']", "focus", function() {
	var t = $(this).attr("pattern");
	!$.os.ios || t && t.length || $(this).attr("pattern", "[0-9]*")
}), $(document).delegate(".ui-text", "tap", function() {
	var t = $(this).find("input");
	t.focus()
}), $.superForm = function(t) {
	var e = {
		_fields: $(t).find("[data-field]"),
		check: function(t) {
			var n = [],
				t = t ? t : {
					not: ""
				};
			console.log(e._fields.length), $(e._fields).each(function(e, i) {
				var a = $(i).data("field"),
					o = $(i).find('[name="' + a + '"]');
				console.log(o.val()), "yes" == o.attr("check-status") || a == t.not ? n.push(1) : ("" == o.val() && (o.parents("[data-field]").find("label").html() || "", o.parents("[data-field]").find(".error").show().html("不能为空")), n.push(0))
			}), console.log(n);
			var i = n.join("").indexOf("0") > -1 ? !1 : !0;
			return i
		}
	};
	return e
}, $(function() {
	function t() {
		function t() {
			var t = $("[view]");
			$.view(t.eq(0).attr("view"));
			try {
				MW.getView($("[view]").eq(0).attr("view")).init()
			} catch (e) {
				
				
				$("[view]") && $("[view]").eq(0).attr("view") && MW.getView($("[view]").eq(0).attr("view")).active()
			}
		}
		var e = window.location.hash;
		if (e) {
			var n = e.split("/"),
				i = n[1],
				a = {};
			if (n.length > 2) {
				var o = n[2].substring(1, n[2].length);
				a = {
					string: o,
					json: {}
				};
				var r = o.split("&");
				$.each(r, function(t, e) {
					var n = e.split("=");
					a.json[n[0]] = n[1]
				})
			}
			i ? $.view(i) : t(), i && $.view(i), window.scrollTo(0, 4), MW.getView && MW.getView(i) && MW.getView(i).active() && MW.getView(i).active(a)
		} else t()
	}
	$(window).on("hashchange", t), setTimeout(function() {
		t()
	}, 300)
}), $.url = {
	setParmsValue: function(t, e, n) {
		var i = t,
			a = $.url.GetUrlParms(),
			o = a[e];
		if (void 0 == o) {
			var r = location.search.substring(1);
			return i += r ? "&" + e + "=" + n : "?" + e + "=" + n
		}
		return updateParms(e, n)
	},
	updateParms: function(t, e) {
		for (var n = function(t, e) {
				return -1 != t.toLowerCase().indexOf(e.toLowerCase()) ? !0 : !1
			}, i = "", a = location.href.substring(0, location.href.indexOf("?") + 1), o = location.search.substring(1), r = o.split("&"), s = 0; s < r.length; s++) {
			var c = r[s].indexOf("=");
			if (-1 != c) {
				var u = r[s].substring(0, c),
					l = r[s].substring(c + 1);
				i += n(u, t) ? u + "=" + e + "&" : u + "=" + l + "&"
			}
		}
		return a + i.substring(0, i.length - 1)
	},
	GetUrlParms: function() {
		for (var t = new Object, e = location.search.substring(1), n = e.split("&"), i = 0; i < n.length; i++) {
			var a = n[i].indexOf("=");
			if (-1 != a) {
				var o = n[i].substring(0, a),
					r = n[i].substring(a + 1);
				t[o] = unescape(r)
			}
		}
		return t
	}
};